package com.acme.bankapp.domain.bank.exception;

import com.acme.bankapp.domain.bank.account.Account;

/**
 * @author Alexander Kotov (kotov.alex.22@gmail.com)
 */

public class NotEnoughFundsException extends BankException{
    private Account account;
    public NotEnoughFundsException(Account account) {
        this.account = account;
    }

    public NotEnoughFundsException(String message) {
        super(message);
    }

    public NotEnoughFundsException(String message, Throwable cause) {
        super(message, cause);
    }

    public NotEnoughFundsException(Throwable cause) {
        super(cause);
    }

    /**
     *
     * @return maximum funds to withdraw for account
     */
    public double getMaximumAmountToWithdraw() {
        return account.getMaximumAmountToWithdraw();
    }

    @Override
    public String getMessage() {
        return String.format("Not enough funds at account, maximum amount to withdraw: %s", getMaximumAmountToWithdraw());
    }
}
